#include "FingerPrint-device.h"
#include <unistd.h>

int main(int argc, char const *argv[])
{

	// 打开设备
	//FingerPrintDevice fingerDev("/dev/ttyUSB0");
	FingerPrintDevice fingerDev("/dev/ttymxc5");

	while(1)
	{
		bool state = fingerDev.isTouchState();
		cout << "touch state :" << state << endl;
		sleep(1);
	}

	// 建立握手信号
	bool ok = fingerDev.handshake();
	cout << "handshake ok:" << ok << endl;
	// sleep(5);

	// // 录指纹
	// for (int i = 0; i < 2; i++) {
	//     ok = fingerDev.detectImage();
	//     cout << "detectImage image ok:" << ok << endl;
	//     if (ok) {
	//         // 生成特质码
	//         ok = fingerDev.generateImageFeature(i + 1);
	//         cout << "makeImageFeature image ok:" << ok << endl;
	//     }
	//     sleep(1);
	// }

	// ok = fingerDev.generateImageTemplate();
	// cout << "make image template: " << ok << endl;

	// ok = fingerDev.storeImageTemplate(1);
	// cout << "make srote image template: " << ok << "1 pos" << endl;

	uint16_t pos;
	cin >> pos;
	sleep(5);

	// 录指纹
	ok = fingerDev.recordFingerprint(pos);
	cout << "record fingerprint ok:" << ok << endl;

	sleep(1);

	pos = 0;
	ok  = fingerDev.verfiyFingerPrint(pos);
	cout << "verfiyFingerPrint  ok:" << ok << ",pos:" << pos << endl;

	return 0;
}
